package com.laputa.service.method.impl;

import com.laputa.dao.model.User;
import com.laputa.model.manager.UserManager;
import com.laputa.service.method.RegisterService;

public class RegisterServiceImpl implements RegisterService {
	private UserManager userManager;
	
	public void setUserManager(UserManager userManager){
		this.userManager = userManager;
	}
	
	public String validate(String username, String password, String confirmpass) {
		if(!password.equals(confirmpass))
			return "两次密码输入不一致";
		if (userManager.getUserByName(username) != null)
			return "用户已存在";
		return null;
	}

	public void save(String name, String password, String email) {
		User user = new User(name, password, email);
		userManager.save(user);
	}
}
